package com.universe.titan.enums;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

public enum BlackTypeEnum {
    FILTER_SAN_FANG_LOCAL(0,"三方黑库(本地)",true,false),
    FILTER_QZ(1,"强制拦截",false,false),
    FILTER_PT(2,"平台过滤",false,false),
    FILTER_USER_TD(3,"用户退订",false,false),
    FILTER_SMS_PB(4,"短信屏蔽",false,false),
    FILTER_SAN_FANG_ONLINE_PC(5,"三方黑库(普尘在线)",true,true),
    FILTER_SAN_FANG_ONLINE_DY(6,"三方黑库(东云在线)",true,true),
    FILTER_SAN_FANG_ONLINE_XZ(7,"三方黑库(小舟在线)",true,true),
    FILTER_SAN_FANG_ONLINE_XZ_PLUS(8,"三方黑库(小舟在线)升级版",true,true);

    private int type;
    private String msg;
    private boolean sf;
    private boolean needReq;

    /**
     * 所有三方黑名单 type
     */
    public static final Set<Integer> Type_sf = Arrays.stream(BlackTypeEnum.values()).filter(BlackTypeEnum::isSf).map(BlackTypeEnum::getType).collect(Collectors.toSet());
    /**
     * 需要发请求的三方黑名单  type
     */
    public static final Set<Integer> Type_sf_needReq = Arrays.stream(BlackTypeEnum.values()).filter(BlackTypeEnum::isNeedReq).map(BlackTypeEnum::getType).collect(Collectors.toSet());

    BlackTypeEnum(int type, String msg, boolean sf, boolean needReq) {
        this.type = type;
        this.msg = msg;
        this.sf = sf;
        this.needReq = needReq;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public boolean isSf() {
        return sf;
    }

    public void setSf(boolean sf) {
        this.sf = sf;
    }

    public boolean isNeedReq() {
        return needReq;
    }

    public void setNeedReq(boolean needReq) {
        this.needReq = needReq;
    }

    public static String getNameByType(int type){
        for (BlackTypeEnum typeEnum : BlackTypeEnum.values()) {
            if (typeEnum.getType()== type){
                return typeEnum.getMsg();
            }
        }
        return null;
    }
}